package example.com.widgetdemo;

import android.app.Activity;
import android.appwidget.AppWidgetManager;
import android.appwidget.AppWidgetProvider;
import android.content.Context;
import android.content.SharedPreferences;
import android.widget.RemoteViews;

/**
 * Created by Android Developer on 06-Jun-16.
 */
public class MottoWidget extends AppWidgetProvider {

    public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {

        for (int i = 0; i < appWidgetIds.length; i++) {
            int currentWidgetId = appWidgetIds[i];
            RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.widget_attach);
            views.setTextViewText(R.id.tv_motto, Utility.getMottoText(context));
            views.setImageViewResource(R.id.bg_root, Utility.getMottoBg(context));
            appWidgetManager.updateAppWidget(currentWidgetId, views);
        }

    }

}
